var mongoose = require('mongoose');

var userSchema = new mongoose.Schema({
  "userId": {
    type: String,
    require: true
  },
  password: {
    type: String,
    require: true
  },
  "userName": {
    type: String,
    require: true
  },
  "userPwd": {
    type: String,
    require: true
  },
  "orderList": Array,
  "cartList": [{
    productId: {
      type: String,
      required: true,
      unique: true
    },
    productName: {
      type: String,
      minlength: 2,
      maxlength: 16,
      required: true
    },
    productImage: {
      type: String,
      required: true
    },
    salePrice: {
      type: Number,
      required: true
    },
    "checked": String,
    "productNum": Number,
  }],
  "addressList": [{
    "addressId": {
      type: String,
      require: true,
      unique: true
    },
    "userName": {
      type: String,
      require: true
    },
    "streetName": {
      type: String,
      require: true
    },
    "postCode": Number,
    "tel": {
      type: Number,
      require: true,
      unique: true
    },
    "isDefault": Boolean
  }]
});
const User = mongoose.model("User", userSchema);

module.exports = {
  User
}